package day5xia;

import org.junit.Test;

import java.util.Objects;

public class Rectangle extends Shape{
    private int width;
    private int height;

    public Rectangle(){

    }

    public double area(){
        return width*height;
    }

    @Override
    public boolean container(Point p){
        boolean xFlag=p.getX() >= getPosition().getX() && p.getX() <= getPosition().getX() + width;
        boolean yFlag=p.getY() >= getPosition().getY() && p.getY() <= getPosition().getY() + height;
        return   xFlag && yFlag;
    }

    public Rectangle(Point position,int width,int height){
        this(position.getX(),position.getY(),width,height);
    }

    public Rectangle(int x,int y,int width,int height){
        super(x,y);
        this.width=width;
        this.height=height;
    }

    public int getWidth() {
        return width;
    }
    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

}
